package benchmark

import "math"

var a [100][100]uint32
var b [100][100]uint32

var row [100][100]uint32

// cpu 缓存应该是最快的 只需要找到a[0,x]的指针，缓存一维数组
func rowRun() {
	length := 100

	for i := 0; i < length; i++ {
		for j := 0; j < length; j++ {
			row[i][j] = a[i][j] + b[i][j]
		}
	}

}

func columnRun() {
	length := 100

	for i := 0; i < length; i++ {
		for j := 0; j < length; j++ {
			row[i][j] = a[j][i] + b[j][i]
		}
	}
}

func randRun() {
	length := 100

	for i := 0; i < length; i++ {
		for j := 0; j < length; j++ {
			row[i][j] = a[j][i] + b[i][j]
		}
	}
}

func initFun() {
	initArray(a)
	initArray(b)
}

func initArray(array [100][100]uint32) {
	length := 100
	for i := 0; i < length; i++ {
		for j := 0; j < length; j++ {
			a[i][j] = uint32(math.Round(float64(100)))
		}
	}
}
